package com.dwxt.community.admin.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.community.admin.service.EditContentService;
import com.dwxt.community.aiequipment.aibin.service.TrashCanService;
import com.dwxt.community.aiequipment.sellmachine.service.SellMachineService;
import com.dwxt.community.service.IntegralService;
import com.dwxt.community.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 智能垃圾分类可视化平台
 */
@RequestMapping("/cms/admin/visual")
@RestController
public class VisualizationControllerAdmin {

    @Autowired
    private UserService userService;
    @Autowired
    private TrashCanService trashCanService;
    @Autowired
    private IntegralService integralService;
    @Autowired
    private SellMachineService sellMachineService;
    @Autowired
    private EditContentService editContentService;

    /**
     * showdoc
     * @catalog 垃圾分类可视化/总用户
     * @title 总用户
     * @method post
     * @description 可视化总用户
     * @url /cms/admin/visual/totalOfUser
     * @return {"status":200,"msg":"SUCCESS","data":{"总参与率":"0.00%","总知晓率":"0.00%","总用户数":7}}
     */
    @RequestMapping("/totalOfUser")
    public BaseResult selectTotalUser(){
       return userService.selectTotal();
    }
    /**
     * showdoc
     * @catalog 垃圾分类可视化/实时投放垃圾数据
     * @title 实时投放垃圾数据
     * @method post
     * @description 可视化总用户
     * @url /cms/admin/visual/trashRecordNow
     * @return {"status":200,"msg":"SUCCESS","data":[{"userName":"秋波","type":1,"integral":0,"communityName":"聚金万佳苑","houseNumber":"30栋50楼1号"},{"userName":"秋波","type":1,"integral":0,"communityName":"聚金万佳苑","houseNumber":"30栋50楼1号"},{"userName":null,"type":5,"integral":0,"communityName":null,"houseNumber":null},{"userName":null,"type":5,"integral":0,"communityName":"拉开距离况佳","houseNumber":null},{"userName":null,"type":5,"integral":0,"communityName":"拉开距离况佳","houseNumber":null},{"userName":null,"type":5,"integral":0,"communityName":"拉开距离况佳","houseNumber":null}]}
     */
    @RequestMapping("/trashRecordNow")
    public BaseResult selectTrashRecord(){
        return integralService.selectTrashRecordList();
    }

    /**
     * showdoc
     * @catalog 垃圾分类可视化/月积分排行
     * @title 月积分排行
     * @method post
     * @description 可视化总用户
     * @url /cms/admin/visual/totalMonthIntegral
     * @return {"status":200,"msg":"SUCCESS","data":[{"communityId":2,"communityName":"拉开距离况佳","sum":0}]}
     */
    @RequestMapping("/totalMonthIntegral")
    public BaseResult selectTotalMonthIntegral(@RequestParam(required = true)  Integer type){
        return integralService.selectTotalMonthIntegral(type);
    }
    /**
     * showdoc
     * @catalog 垃圾分类可视化/智能垃圾箱设备状态
     * @title 智能垃圾箱状态
     * @method post
     * @description 可视化总用户
     * @url /cms/admin/visual/equipmentStatus
     * @return {"status":200,"msg":"SUCCESS","data":[{"deviceId":"572173143134544105D5FF32","wsTime":"2020-05-20 15:03:52","sortSum":4,"batteryVoltage":0,"binCount":4,"batteryTemperatur":0,"mainboardTemperature":0,"dailyElectricity":0,"dailyCharge":0,"chargingCurrent":0,"firmwareVersion":0,"signalIntensity":23,"iccId":"595604130f1246624632","deviceGpsLng":0.0,"deviceGpsLat":0.0,"exceptions":[],"sortList":[],"trashInners":[]}]}
     */
    @RequestMapping("/equipmentStatus")
    public BaseResult selectEquipmentStatus(){
        return trashCanService.selectAllEquipments();
    }
    /**
     * showdoc
     * @catalog 垃圾分类可视化/智能垃圾箱数量
     * @title 智能垃圾箱数量
     * @method post
     * @description 可视化总用户
     * @url /cms/admin/visual/equipmentNumbers
     * @return {"status":200,"msg":"SUCCESS","data":11}
     */
    @RequestMapping("/equipmentNumbers")
    public BaseResult selectEquipmentNumbers(){
        return trashCanService.selectEquipmentNumbers();
    }


    /**
     * 礼品兑换次数
     */
    @RequestMapping("/giftExchangeTimes")
    public BaseResult selectGiftTimes(){ return sellMachineService.selectGiftExchangeTimes();}

    /**
     * 编辑数据接口列表
     */
    @RequestMapping("/editContentList")
    public BaseResult selectEditList(){return editContentService.selectAll();}

    /**
     * 各个街道参与情况表
     */
    @RequestMapping("/selectTotalByStreetList")
    public BaseResult selectTotalByStreetList(){return userService.selectTotalByStreetList();}
}

